<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">
      <img
        src="../../assets/common/语言切换 (1).svg"
        class="img"
        align="absmiddle"
      >
      <i class="el-icon-arrow-down el-icon--right" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh" :disabled="$i18n.locale === 'zh'">
        中文</el-dropdown-item>
      <el-dropdown-item
        command="en"
        :disabled="$i18n.locale === 'en'"
      >英文</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  name: 'Lang',
  data() {
    return {}
  },
  computed: {},
  created() {},
  methods: {
    handleCommand(command) {
      this.$i18n.locale = command
      // window.location.reload()
    }
  }
}
</script>

<style lang="scss" scoped>
.el-dropdown {
  margin: 0 30px;
}
.img {
  width: 30px;
  height: 30px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.demonstration {
  display: block;
  color: #8492a6;
  font-size: 14px;
  margin-bottom: 20px;
}
</style>
